<template>
  <div class="u-p-20">
    <el-card shadow="never">
      <div slot="header">
        <b class="u-f-16">
          <span v-if="objForm.id">编辑</span>
          <span v-else>添加</span>用户等级
        </b>
        <div class="u-right u-5mt">
          <el-button
            type="success"
            size="small"
            icon="el-icon-document-checked"
            @click="submitForm('objForm')"
            v-if="hasPerm('userLevelEdit')"
          >提交保存</el-button>
          <el-button size="small" icon="el-icon-back" @click="$router.go(-1)">返回</el-button>
        </div>
      </div>
      <el-form :model="objForm" :rules="rules" ref="objForm" label-width="100px" class="u-form">
        <el-form-item label="等级名称">
          <el-input v-model="objForm.level_name" placeholder="等级名称"></el-input>
        </el-form-item>

        <el-form-item label="等级价格">
          <el-input v-model="objForm.level_price" placeholder="等级价格"></el-input>
        </el-form-item>

        <el-form-item label="等级级别">
          <el-select v-model="objForm.level_number" placeholder="请选择等级级别">
            <el-option label="1" value="1"></el-option>
            <el-option label="2" value="2"></el-option>
            <el-option label="3" value="3"></el-option>
            <el-option label="4" value="4"></el-option>
            <el-option label="5" value="5"></el-option>
            <el-option label="6" value="6"></el-option>
            <el-option label="7" value="7"></el-option>
            <el-option label="8" value="8"></el-option>
            <el-option label="9" value="9"></el-option>
            <el-option label="10" value="10"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="等级时间">
          <el-col :span="11">
           <el-input v-model="objForm.level_day" placeholder="请选输入时间数量"></el-input>
          </el-col>
          <el-col class="line" :span="1">-</el-col>
          <el-col :span="11">
            <el-select v-model="objForm.level_unit" placeholder="请选择计量单位">
            <el-option label="天" value="D"></el-option>
            <el-option label="月" value="M"></el-option>
            <el-option label="年" value="Y"></el-option>
          </el-select>
          </el-col>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
import commonEdit from "@/mixins/common-edit";
export default {
  mixins: [commonEdit],
  data() {
    return {
      apiName: "userLevel",
      backRoute: "userLevelIndex", //成功跳转地址
      objForm: {
        id: "",
        level_name: "", //等级名称
        level_number: "", //等级级别
        level_price: "", //等级价格
        level_day: "", //等级天数
        level_unit: "" //等级单位
      }
    };
  },
  methods: {
    afterGetInfo() {
      //初始化数据
      this.objForm.level_unit =
        this.objForm.level_unit == "Y"
          ? "Y"
          : this.objForm.level_unit == "M"
          ? "M"
          : "D";
    }
  },
  created() {}
};
</script>
